<template>
	<view class="full box relative bg-primary flex-col stock-record">
		<view class="w-wrap">
			<view class="w-inner">
				<mescroll-uni @init="mescrollInit" :fixed="false" @down="downCallback" @up="upCallback">
					<view class="record-list">
						<view class="record-item" v-for="(item,index) in list" :key="index">
							<view class="item-details">
								<image :src="item.image" class="item-image" mode="aspectFill"></image>
								<view class="item-info">
									<!-- <text class="pack-name">{{ item.name }}</text> -->
									<view class="pack-content">
										<text class="common-text">套餐内容：</text>
										<text class="active-text">{{item.taocan_neirong}}</text>
										<!-- <text class="common-text">[0.28元/升]</text> -->
									</view>
									<text class="desc-item">时限：{{item.day_num}}天</text>
									<view class="item-price">
										<text class="price-label">价格：</text>
										<text class="price-value">¥{{ item.order_amount }}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</mescroll-uni>
			</view>
		</view>
	</view>
</template>

<script>
	import { request, showLoading, toast } from "@/utils/tool.js";
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import currency from "currency.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				list: [],
			}
		},
		methods: {
			async upCallback(ev) {
				const { num, size } = ev
				const resp = await request({
					url: "/beihuo/beihuoorderlists",
					method: "GET",
					data: {
						page_no: num,
						page_size: size
					}
				})
				if (num === 1) this.list = []
				const { lists, count } = resp.data
				this.list.push(...lists.map(item=>{
          let image = ""
          if(item.rechargeconfig && item.rechargeconfig.length > 0){
            const [target] =item.rechargeconfig
            image = target?.recharge_config_arr?.image
          }
          item.image = image
          return item
        }))
				this.mescroll.endBySize(lists.length, count)
			}
		}

	}
</script>

<style lang="scss" scoped>
	.stock-record {
		.record-list {
			padding-top: 24rpx;

			.record-item {
				padding: 20rpx 46rpx;
				background: #fff;
				margin-bottom: 22rpx;

				&:last-child {
					margin-bottom: 0;
				}

				.item-details {
					display: flex;
					align-items: flex-start;

					.item-number-box {
						padding: 0 10rpx;
						display: flex;
						align-items: center;
						margin-top: 8rpx;

						.number-icon {
							width: 32rpx;
							height: 32rpx;
						}

						.number-value {
							font-weight: 400;
							font-size: 24rpx;
							color: rgba(0, 0, 0, 0.9);
							line-height: 40rpx;
							width: 120rpx;
							text-align: center;
						}
					}

					.item-info {
						margin-left: 10rpx;
						display: flex;
						flex-flow: column;

						.desc-item {
							font-size: 22rpx;
							color: #737373;
							line-height: 44rpx;
						}

						.item-price {
							font-size: 26rpx;
							color: #737373;
							line-height: 44rpx;

							.price-value {
								color: #FF0000;
							}
						}

						.pack-content {
							font-weight: 400;
							font-size: 22rpx;
							line-height: 44rpx;

							.active-text {
								color: #FF0000;
							}

							.common-text {
								color: #737373;
							}
						}

						.pack-name {
							font-size: 28rpx;
							color: #515151;
							line-height: 44rpx;
						}
					}

					.item-image {
						width: 160rpx;
						height: 177rpx;
					}
				}

				.item-header {
					display: flex;
					align-items: center;
					margin-bottom: 2rpx;

					.item-circle {
						width: 12rpx;
						height: 12rpx;
						background: #26CF1F;
						border-radius: 50%;
					}

					.device-name {
						font-weight: 400;
						font-size: 28rpx;
						color: #4C4C4C;
						line-height: 44rpx;
						margin-left: 8rpx;
					}
				}
			}
		}
	}
</style>